package xian.woniu.config;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import xian.woniu.util.ResultVO;

/**
 * @author SongHang
 * @time 2022/06/13 14:53:16
 */
@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public ResultVO handleArithmeticException(ArithmeticException e) {
        // for debug
        e.printStackTrace();
        throw e;
    }


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResultVO handleException(Exception e) {
        // for debug
        e.printStackTrace();
        return ResultVO.failure(e.toString());
    }
}
